<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo Yii::$app->name;?> 后台管理</title>
<?php $this->HeaderView(['slide']);?>
</head>
<body class="view_form" id="view_form_Admin">
<form id="view-form-form" class="view-form-form" method="post" action="<?php echo $this->createUrl([$model->id ? 'admin/update' : 'admin/create', 'id'=>$model->id ? $model->id : null]);?>" enctype="multipart/form-data">
	<input type="hidden" id="id" name="Admin[id]" value="<?php echo $model->id;?>">
       <input type="hidden" id="reg_time" name="Admin[created_at]" value="<?php echo $model->created_at ? $model->created_at:time();?>">
       <input type="hidden" id="status" name="Admin[status]" value="<?php echo $model->status ? $model->status:0;?>">
<?= base\YiiMobo::csrfToken();?>
             <table class="view-form-input" border="0" cellspacing="0" cellpadding="0" width="100%">
                <thead>
                    <tr>
                        <th valign="top" class="td-title"><label for="catid">用户名：</label></th>
                        <td class="td-input"><input type="text" class="input-text"  id="username" name="Admin[username]" value="<?php echo $model->username;?>" <?php if ($model->id) echo ' disabled="disabled" style="cursor:not-allowed; 
"'?>  ></td>
                    </tr>
                
                                        <tr>
                        <th valign="top" class="td-title"><label for="catid">邮箱：</label></th>
                        <td class="td-input"><input type="text" class="input-text" id="email" name="Admin[email]" value="<?php echo $model->email;?>"></td>
                    </tr>
                    <tr>
                        <th valign="top" class="td-title"><label for="catid">密码：</label></th>
                        <td class="td-input"><input type="password" class="input-text" id="password" name="Admin[password]" value="">
                        	<input type="hidden" id="input" name="Admin[input]"></td>
                    </tr>
                    <tr>
						<th valign="top" class="td-title"><label for="id">确认密码：</label></th>
						<td class="td-input"><input type="password" class="input-text" id="repass" name="Admin[repass]" value="" ></td>
					</tr>
                                        <tr>
                        <th></th>
                        <td><input type="submit" value="提交" name="sbmt" class="btn-submit mt-10">
                            </td>
                    </tr>
                        </tbody>
                    
            </table>
    </form>
</form>
<script type="text/javascript">
$(function(){
	
	$("#view-form-form").validate({
		rules: {
            "Admin[reg_time]":"required",                           
	        "Admin[username]":{
		  required:true,
	         remote: {
	               	   type: "get",
	                   url: "<?php echo $this->createUrl('admin/checkname');?>",
	                   data: {
	                   	   username: function() {
						      return $("#username").val();
						  },
						  id: function() {
						      return '<?php echo $model->id?>';
						  },
	                   },
	                   dataType: "html",
	                   dataFilter: function(data, type) {
	                   	   if (data == "true"){
	                            return true;
	                       }else{
	                            return false;
						   }
	                   }
	               }
				},
			//"Admin[password]":"required",
	        "Admin[repass]":{
				required:true,
    			equalTo:"#password"
					},
	        "Admin[repass]":{
    			equalTo:"#password"
					},
	        "Admin[email]":{
                    required:true,
                    email: true
                     },
	       
		},
		messages: {
			"Admin[username]":{
				required:"请输入用户名",
				remote:"该管理员已存在"
				},
			"Admin[email]":{
                required:"请输入邮箱",
					email: "请输入正确邮箱"
				},
			//"Admin[password]":"请输入密码",
			"Admin[repass]":{
				required:"请输入确认密码",
				equalTo:"与密码不一致"
				},
		}, 
	});

	
	//添加位置导航文字 请修改
	admin_location('会员管理 > 管理员管理 > <?php echo $model->id ? '编辑管理员' : '添加管理员';?>');
});


</script>
<?php $this->FooterView();?>
</body>
</html>
